package com.edgelight.controller;

import com.edgelight.pojo.resp.BaseResp;

import com.edgelight.utils.UploadUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
public class UploadController {



    @PostMapping("/upload")
    public BaseResp upload(@RequestParam("file") MultipartFile multipartFile){
        String upload = UploadUtils.upload(multipartFile);
        if (StringUtils.isEmpty(upload)){
            return new BaseResp().ERROR();
        }
        return new BaseResp(1,"ok",upload,null);
    }
}
